/**
 * This class contains unit tests for validating the behavior of 
 * UpdCampaignOnLeadOwnerChg trigger.
 *
 */
@isTest(Seealldata=true)
private class TestUpdCampaignOnLeadOwnerChg {

    static testMethod void myUnitTest() {
        User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
        System.runAs (thisUser) {

            Test.startTest();
            
            Group g;
            g = new Group();
            g.Type = 'Queue';
            g.Name = 'West - Default(ACC)';
            g.DeveloperName = 'ACCQueue';
            insert g;  
            
            Group g1 = [Select id from group where DeveloperName = 'ACCQueue'];
            QueueSObject q = new QueueSObject(SObjectType='Lead', QueueId=g1.Id);
            insert q;     
            
            Lead l=new Lead();
            l.email='john@john.com';
            l.firstname='John';
            l.HasOptedOutOfEmail=false;
            l.lastname='Coppedge';
            l.RecordTypeId=Schema.sObjectType.Lead.getRecordTypeInfosByName().get('West - Prospective Student').getRecordTypeId();
            l.Personal_Email__c='john@john.com';
            l.status='Contacted';
            l.phone='(801) 555-5556';
            DateTime birthDate= DateTime.now(); //DateTime variable
            String birthDate_Formatted_Date = birthDate.format('yyyy-MM-dd');
            l.Birth_Date__c=date.valueof(birthDate_Formatted_Date);
            l.Work_Phone__c='(801) 555-5556';
            l.Country = 'Mexico';
            //l.OwnerId = g2.id;//'005c0000000QOLW'; //
            
            insert l;
            
            Campaign cm = new Campaign(Name = 'UnitTest', Owner_Assignment__c = g1.id);
            cm.RecordTypeId = Schema.sObjectType.Campaign.getRecordTypeInfosByName().get('West - Five9 Campaign').getRecordTypeId();
            insert cm;
                    
            l.OwnerId = g1.id;
            update l;
            
            
            
            Test.stopTest();
            
        }            
    }
}